package com.ybkj.o2o.sales.common;

/**
 * @author Shine.
 *
 */
public class Pager {

  private static final ThreadLocal<Integer> OFFSET = new ThreadLocal<Integer>();

  private static final ThreadLocal<Integer> LIMIT = new ThreadLocal<Integer>();

  public static Integer getOffset() {
    return OFFSET.get();
  }

  public static Integer getLimit() {
    return LIMIT.get();
  }

  public static void setOffset(Integer offset) {
    OFFSET.set(offset);
  }

  public static void setLimit(Integer limit) {
    LIMIT.set(limit);
  }

  public static Integer getPage() {

    return OFFSET.get() / LIMIT.get();
  }

  public static void clear() {
    OFFSET.remove();
    LIMIT.remove();
  }
}
